package com.chuang.bootplus.controller.email;

import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;
import com.chuang.bootplus.base.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: TODO email Test
 * @author nuo
 * @date 2022/10/11 6:46
 * @version 1.0
 */
@Api(tags = {"email"})
@RequestMapping("/test")
@RestController
public class EmailTestController {

    @Autowired
    MailAccount mailAccount;

    @PostMapping("/sendEmail")
    @ApiOperation("发送邮件...")
    public ApiResponse<String> sendMsg(String email, String subject, String content){
        String id = MailUtil.send(mailAccount, email, subject, content, false);
        return new ApiResponse<>(id);
    }

}
